﻿using System;
using System.IO.Ports;
using System.Collections.Generic;
using System.Globalization;

namespace MiReaderLib
{
    static class SerialPortExtension
    {
        public static void WriteBytes(this SerialPort sp, params byte[] bytes)
        {
            sp.Write(bytes, 0, bytes.Length);
        }

        public static void WriteByte(this SerialPort sp, byte @byte)
        {
            WriteBytes(sp, @byte);
        }

        public static void WriteHexaStr(this SerialPort sp, string hexaString)
        {
            foreach (string part in hexaString.Split(' ', ',', ';', ':'))
                WriteByte(sp, byte.Parse(part, NumberStyles.HexNumber));
        }
    }
}
